package com.cskaoyan.method;

/*
        定义比较两个数据是否相等的方法。
        参数类型分别为
        a. 两个byte类型
        b. 两个short类型
        c. 两个int类型
        d. 两个long类型，并在main方法中进行测试

 */
public class Demo4OverloadExercise {

    public static void main(String[] args) {
        byte a = 10;
        byte b = 10;
        boolean result;
        // equal(byte a, byte b)
        //result = equal(a, b);
        //System.out.println(result);

        // equal(int a, int b)
        //result = equal(10, 20);
        //System.out.println(result);

        // equal(long a, long b)
        //result = equal(10L, 20L);
        //System.out.println(result);

        short s = 10;
        // a byte
        // s short
        // equal(short a, short b)，这里jvm找到了和我们传递的参数最接近的重载
        result = equal(a, s);
        System.out.println(result);
    }

    public static boolean equal(byte a, byte b) {
        System.out.println("equal(byte a, byte b)");
        return a == b;
    }

    public static boolean equal(short a, short b) {
        System.out.println("equal(short a, short b)");
        return a == b;
    }

    public static boolean equal(int a, int b) {
        System.out.println("equal(int a, int b)");
        return a == b;
    }

    public static boolean equal(long a, long b) {
        System.out.println("equal(long a, long b)");
        return a == b;
    }

}
